package com.zqxq.lottery.service.sys.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zqxq.lottery.entity.po.user.UserAgentPO;
import com.zqxq.lottery.mapper.user.UserAgentMapper;
import com.zqxq.lottery.service.sys.IUserAgentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author 苦智
 * @date 2018/7/9 17:29
 * @description
 * @ClassName UserAgentServiceImpl
 */
@Service
public class UserAgentServiceImpl extends ServiceImpl<UserAgentMapper,UserAgentPO> implements IUserAgentService {
    @Autowired
    private UserAgentMapper userAgentMapper;
    @Override
    public Map<String, Object> getUserAgentData(String startTime, String endTime, String agentId, Integer timeType, Integer pageNo, Integer pageSize) {
        List<Map<String,String>> agentNames = userAgentMapper.selectAgentNameList();
        Map<String, Object> allAgentData = userAgentMapper.getAllAgentOrderData(startTime, endTime, agentId);
        Map<String, Object> allAgentUserData = userAgentMapper.getAllAgentUserData(startTime, endTime, agentId);
        allAgentData.putAll(allAgentUserData);
        Page<Map<String,Object>> page = new Page(pageNo,pageSize);
        List<Map<String,Object>> mapList = null;
        if (timeType == 2){
            mapList = userAgentMapper.queryDayManageData(page,startTime,endTime,agentId);
        }else {
            mapList = userAgentMapper.queryMonthManageData(page,startTime,endTime,agentId);
        }
        page.setRecords(mapList);
        allAgentData.put("agentNameList",agentNames);
        allAgentData.put("page",page);
        return allAgentData;
    }
}
